<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>上课时间管理</title>
	<%
    	String path = request.getContextPath();
	    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
    %>
	<c:set var="path" value="<%=basePath %>"></c:set>
 	<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" />
 	<link href="css/public.css" rel="stylesheet" />
 	
 	<!--皮肤文件-->
	<link rel="stylesheet" type="text/css" href="./css/easyui.css" />
	<!--图标文件-->
	<link rel="stylesheet" type="text/css" href="./css/icon.css" />
	<link rel="stylesheet" type="text/css" href="./css/demo.css" />
	<!--jquery文件-->
	<script type="text/javascript" src="./js/jquery.min.js"></script>
	<!--easyui核心文件-->
	<script type="text/javascript" src="./js/jquery.easyui.min.js"></script>
	<!--对应的语言包-->
	<script type="text/javascript" src="./js/easyui-lang-zh_CN.js"></script>
</head>
<body> 
	<table id="dg1"></table> 
	<script type="text/javascript">
		//数据表格
		$(function(){
			dolog();
		});
		function dolog(){
			 	$('#dg1').datagrid({loadFilter:pagerFilter}).datagrid({    
			 	url:'timeList',
			    iconCls: 'icon-edit',  //加载图标
				singleSelect: true,    //单行选中
				rownumbers:true,
				pagination:true,//开启分页功能
				pageSize:5,    
				pageNumber:1,
				pageList: [5,10,20],
				border:false,
				sortName:'t_id',
				sortOrder:'desc',
				fitColumns:true,
				striped:true,
				fit:true,
			    columns:[[    
			    	{
			        	field:'t_id',
			        	title:'编号',
			        	width:80,
			        	align:'center'
			        },{
			        	field:'classInfo',
			        	title:'班级名称',
			        	width:80,
			        	align:'center',
			        	formatter:function(value, row, index){
							console.log(row);
			        		return row.classInfo.clazz_name;
			        	}
			        },{
			        	field:'uptime',
			        	title:'上课时间',
			        	width:80,
			        	align:'center'
			        },{
			        	field:'breaktime',
			        	title:'下课时间',
			        	width:80,
			        	align:'center'
			        },{
			        	field:'latetime',
			        	title:'晚自习时间',
			        	width:80,
			        	align:'center'
			        },{
			        	field:'ontime',
			        	title:'开空调时间',
			        	width:80,
			        	align:'center'
			        },{
			        	field:'offtime',
			        	title:'关空调时间',
			        	width:80,
			        	align:'center'
			        },{   
			        	field:'operate',
			        	title:'操作',
			        	align:'center',
			        	width:$(this).width()*0.2,
			        	formatter:function(value, row, index){
			        		var str= '<a href="updatetime?mytid='+row.t_id+'" name="opera1" class="easyui-linkbutton"></a>';
			        		return str;
			        	}
			        }
			    ]],
			    onLoadSuccess:function(data){
			            $("a[name='opera1']").linkbutton({text:'修改时间',plain:true,iconCls:'icon-save'});
			    },
			   
			}); 
		}
		//前台分页功能
		function pagerFilter(data){
		    if (typeof data.length == 'number' && typeof data.splice == 'function'){    // 判断数据是否是数组
		        data = {
		            total: data.length,
		            rows: data
		        }
		    }
		    var dg = $(this);
		    var opts = dg.datagrid('options');
		    var pager = dg.datagrid('getPager');
		    pager.pagination({
		        onSelectPage:function(pageNum, pageSize){
		            opts.pageNumber = pageNum;
		            opts.pageSize = pageSize;
		            pager.pagination('refresh',{
		                pageNumber:pageNum,
		                pageSize:pageSize
		            });
		            dg.datagrid('loadData',data);
		        }
		    });
		    if (!data.originalRows){
		        data.originalRows = (data.rows);
		    }
		    var start = (opts.pageNumber-1)*parseInt(opts.pageSize);
		    var end = start + parseInt(opts.pageSize);
		    data.rows = (data.originalRows.slice(start, end));
		    return data;
		}
	</script>
</body>
</html>